$(function () {
    $.ajax({
        url: APP_PATH + "/checkLoginStatus.action" ,
        type: "get",
        dataType: "json",
        success: function (data) {
            // alert(U_id);
            // alert(data.user_name);
            if (data.user_name == undefined) {   // 未登录
                $(".head_logout").show();
                $(".head_login").hide();
                $(".head_login").hide();
            } else {    // 已登录

                userid = data.user_id;
                username = data.user_name;
                email = data.user_email;
                userPhoto = data.user_img;
                gender = data.user_gender;
                console.log("img: " + userPhoto);
                if(userPhoto != undefined && userPhoto != ""){
                    $("#userImg").attr("src",APP_PATH + userPhoto);
                }else{
                    $("#userImg").attr("src",APP_PATH + "/static/img/head.png");
                }
                $(".head_logout").hide();
                $(".head_login").show();
                $(".head_login").show();
            }
        }
    })
});
$('#logout').on("click",function () {
    // alert("get");
    $.ajax({
        url:"/bbs/logout.action",
        type:"GET",
        contentType: false,
        cache:false,
        success:function (res) {
            // alert("退出登录");
            console.log(res);
            window.location.href("/bbs/");
        },fail: function (err) {
            console.log(err);
            alert("failed");
        }
    })
})


